package com.qianfeng.smartdevice.pojo;


import com.fasterxml.jackson.annotation.JsonProperty;
import com.qianfeng.smartdevice.enums.CheckType;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;

public class SysCategory implements CheckNull{
  @JsonProperty("cId")
  private Long cId;
  private String categoryName;
  private String txCommand;
  private String rxCommand;
  private String commandName;
  private Long status;
  private java.util.Date createTime;
  private String createBy;
  private java.util.Date updateTime;
  private String updateBy;

  @Override
  public boolean isEmpty(CheckType type) {
    //现在这个方法遇到了问题,添加和更新的时候判断标准不一样
    switch (type) {
      case ADD:
        return !StringUtils.hasText(categoryName);//对于分类来说,主要是分类的名字
      case UPDATE:
        return cId == null || cId < 1 || (ObjectUtils.isEmpty(categoryName)&&ObjectUtils.isEmpty(txCommand)&&ObjectUtils.isEmpty(rxCommand)&&ObjectUtils.isEmpty(commandName)&&ObjectUtils.isEmpty(status));

    }
    return false;
  }

  public Long getCId() {
    return cId;
  }

  public void setCId(Long cId) {
    this.cId = cId;
  }


  public String getCategoryName() {
    return categoryName;
  }

  public void setCategoryName(String categoryName) {
    this.categoryName = categoryName;
  }


  public String getTxCommand() {
    return txCommand;
  }

  public void setTxCommand(String txCommand) {
    this.txCommand = txCommand;
  }


  public String getRxCommand() {
    return rxCommand;
  }

  public void setRxCommand(String rxCommand) {
    this.rxCommand = rxCommand;
  }


  public String getCommandName() {
    return commandName;
  }

  public void setCommandName(String commandName) {
    this.commandName = commandName;
  }


  public Long getStatus() {
    return status;
  }

  public void setStatus(Long status) {
    this.status = status;
  }


  public java.util.Date getCreateTime() {
    return createTime;
  }

  public void setCreateTime(java.util.Date createTime) {
    this.createTime = createTime;
  }


  public String getCreateBy() {
    return createBy;
  }

  public void setCreateBy(String createBy) {
    this.createBy = createBy;
  }


  public java.util.Date getUpdateTime() {
    return updateTime;
  }

  public void setUpdateTime(java.util.Date updateTime) {
    this.updateTime = updateTime;
  }


  public String getUpdateBy() {
    return updateBy;
  }

  public void setUpdateBy(String updateBy) {
    this.updateBy = updateBy;
  }




  @Override
  public String toString() {
    return "SysCategory{" +
            "cId=" + cId +
            ", categoryName='" + categoryName + '\'' +
            ", txCommand='" + txCommand + '\'' +
            ", rxCommand='" + rxCommand + '\'' +
            ", commandName='" + commandName + '\'' +
            ", status=" + status +
            ", createTime=" + createTime +
            ", createBy='" + createBy + '\'' +
            ", updateTime=" + updateTime +
            ", updateBy='" + updateBy + '\'' +
            '}';
  }
}
